import java.util.*;

public class TestRandomWalk {
    public static void main(String[] args) {
        randomWalk();
    }
    public static void randomWalk() {
        int position = 0;
        int max = 0;
        double randomStep;
        System.out.println("position = " + position);
        while (position > -3 && position < 3) {
            randomStep = Math.random();
            if (randomStep < 0.5)
                position += 1;
            else
                position -= 1;
            System.out.println("position = " + position);
            if (position > max)
                max = position;
        }
        System.out.println("max position = " + max);
    }
}